define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'baobiao/produce/index' + location.search,
                    table: 'produce',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate: false},
                        {field: 'factory_id', title: "厂区"},
                        {field: 'group_id', title: "组别"},
                        {field: 'name', title: "批次", operate: 'LIKE'},
                        {field: 'jiaguangriqi', title: "加光日期",operate: false},
                        {field: 'a1', title: "加光数(剩余种兔数)",operate: false},
                        {field: 'a2', title: "种兔更新数量",operate: false},
                        {field: 'peizhongriqi', title: "配种日期",operate: false},
                        {field: 'b1', title: "配种数",operate: false},
                        {field: 'motairiqi', title: "摸胎日期",operate: false},
                        {field: 'c1', title: "受胎数",operate: false},
                        {field: 'c2', title: "受胎率",operate: false},
                        {field: 'chanzairiqi', title: "产仔日期",operate: false},
                        {field: 'd1', title: "产仔窝数",operate: false},
                        {field: 'd2', title: "产仔数",operate: false},
                        {field: 'd3', title: "产仔率",operate: false},
                        {field: 'd4', title: "窝均产仔数",operate: false},
                        {field: 'd5', title: "产活仔数",operate: false},
                        {field: 'd6', title: "窝均产活仔数",operate: false},
                        {field: 'e1', title: "选留窝数",operate: false},
                        {field: 'e2', title: "选留数",operate: false},
                        {field: 'e3', title: "窝均带仔数",operate: false},
                        // {field: 'group_name', title: "带仔率",operate: false},
                        // {field: 'group_name', title: "理论断奶日期",operate: false},
                        {field: 'duannairiqi', title: "断奶日期",operate: false},
                        {field: 'f1', title: "断奶数",operate: false},
                        // {field: 'group_name', title: "断奶出售",operate: false},
                        {field: 'f2', title: "断奶成活率",operate: false},
                        {field: 'f3', title: "断奶均重",operate: false},
                        // TODO
                        {field: 'f4', title: "断奶出售数",operate: false},
                        {field: 'f5', title: "断奶出售重量",operate: false},

                        {field: 'chulanriqi', title: "出栏日期",operate: false},

                        // TODO
                        {field: 'g1', title: "生长兔销售",operate: false},
                        {field: 'g2', title: "出栏总数",operate: false},
                        // {field: 'group_name', title: "出栏成活率",operate: false},
                        {field: 'g3', title: "出栏重",operate: false},
                        {field: 'g4', title: "出栏种兔数",operate: false},
                        {field: 'g5', title: "出栏商品兔数",operate: false},
                        // {field: 'group_name', title: "出栏种兔品系",operate: false},
                        // {field: 'group_name', title: "断奶料肉比",operate: false},
                        // {field: 'group_name', title: "全程料肉比",operate: false},
                        // {field: 'group_name', title: "批成活率",operate: false},
                        // {field: 'group_name', title: "淘汰种母兔",operate: false},
                        // {field: 'group_name', title: "死亡种母兔",operate: false},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
